import React from "react";
import { notFound } from "next/navigation";

import BranchGuard from "@/components/auth/BranchGuard";
import { isValidBranchParam } from "@/lib/frontend/params";

export default async function BranchLayout({ children, params }) {
	const { branch } = await params;

	if (!isValidBranchParam(branch)) {
		notFound();
	}

	return <BranchGuard branch={branch}>{children}</BranchGuard>;
}
